package com.alice.sentinel.controller;


import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alice.sentinel.common.utils.R;
import com.alice.sentinel.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


/**
 * 
 *
 * @author fox
 * @email 2763800211@qq.com
 * @date 2021-01-28 15:53:24
 */
@RestController
@RequestMapping(value = "/user")
public class UserController {

    @Autowired(required = false)
    OrderFeignService orderFeignService;

    @RequestMapping(value = "/findOrderByUserId/{id}")
    //@SentinelResource(value = "findOrderByUserId",blockHandler = "handleException")
    public R findOrderByUserId(@PathVariable("id") Integer id) {

//        try {
//            // 模拟测试并发线程数限流
//            Thread.sleep(900);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        //feign调用
        R result = orderFeignService.findOrderByUserId(id);

        return result;
    }




}
